package com.wutuo.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 标题、简要说明. <br> 类详细说明.
 * <p/>
 * Copyright: Copyright (c) 2016年04月30日 14:53
 * <p/>
 * Company:
 * <p/>
 *
 * @author Kent
 * @version 1.0.0
 */
public enum TaskType {

    OTHER("other"),
    NOON_ORDER("noon_order"),
    NOON_LEAVE("noon_leave"),
    NIGHT_ORDER("night_order"),
    NIGHT_LEAVE("night_leave");

    private String value;

    /**
     * 私有构造函数
     */
    private TaskType(String value) {
        this.value = value;
    }

    /**
     * 返回枚举值的字符串值
     *
     * @return
     */
    public String getValue() {
        return value;
    }

    public static TaskType get(String value) {
        TaskType[] values = TaskType.values();
        for (TaskType item : values) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return OTHER;
    }

    public static String getText(String value) {
        if (StringUtils.isBlank(value)) {
            return "其他";
        }

        switch (value) {
            case "noon_order":
                return "午托点名";
            case "noon_leave":
                return "午托校接";

            case "night_order":
                return "晚托点名";
            case "night_leave":
                return "晚托校接";
            default:
                return "其他";
        }

    }

    public static TaskType getByText(String text) {
        if (StringUtils.isBlank(text)) {
            return OTHER;
        }

        switch (text) {
            case "午托点名":
                return NOON_ORDER;
            case "午托校接":
                return NOON_LEAVE;

            case "晚托点名":
                return NIGHT_ORDER;
            case "晚托校接":
                return NIGHT_LEAVE;
            default:
                return OTHER;
        }
    }

    public static int getIntValue(String type) {
        if (StringUtils.isBlank(type)) {
            return 0;
        }

        switch (get(type)) {
            case NOON_ORDER:
                return 5;
            case NOON_LEAVE:
                return 4;
            case NIGHT_ORDER:
                return 3;
            case NIGHT_LEAVE:
                return 2;
            case OTHER:
                return 1;
            default:
                return 0;
        }
    }
}
